package ucm.module;

import air_cp5620.UserInfo;
import air_cp5620.dao.DAO;
import java.sql.*;
import java.util.Vector;

public class Main_SelManAccM {

    private DAO dbCon = null;
    public Main_SelManAccM() {
        dbCon = new DAO();
    }


    public Vector<UserInfo> LoadDataFormDB()
    {
        String sql = null;
        Vector<UserInfo> userInfo_vec = new Vector<UserInfo>();
        Connection con = dbCon.getConnection();
        if (con == null) {
            return null;
        }
        try {
            Statement stmt = con.createStatement(ResultSet.CONCUR_UPDATABLE, ResultSet.CONCUR_UPDATABLE);
            sql = "select * from tbl_user";
            ResultSet res = stmt.executeQuery(sql);
            
            while(res.next())
            {
                UserInfo userinfo = new UserInfo(res.getString("userid"),
                        res.getString("password"),
                        res.getString("roleid"),
                        res.getString("isdelete"));
                userInfo_vec.add(userinfo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return userInfo_vec;
    }
    
}
